<?php
	$sql = new db();
	$value = 1;
	if (isset($_GET['start']) && !empty($_GET['start']))
		$start = $_GET['start'];
	else
		$start = '0';
		
	if (isset($_GET['numpage']) && !empty($_GET['numpage']))
		$numpage = $_GET['numpage'];
	else
		$numpage = '1';
		
	if (isset($_GET['end']) && !empty($_GET['end']))
		$end = $_GET['end'];
	else
		$end = '10';
	if (isset($_GET['tri']) && !empty($_GET['tri']))
	{
		$ordre = " ASC ";
		if (isset($_GET['cmp']) && ($_GET['tri'] == $_GET['cmp']))
		{ 
			if (strpos($_GET['ordre'], "ASC") === false)
				$ordre = " ASC ";
			else
				$ordre = " DESC ";
		}	
		$tri = " ORDER BY ".$_GET['tri'].$ordre;
	}
	else
		$tri = "";
	$req = "SELECT COUNT(*) AS total FROM ".$_GET['idtab'];
	$sql->query($req);
	$total = $sql->fetch_array();
	$total = $total['total'] - $start;
	$nb_page = ceil($total / $end);
	$start2 = ($numpage - 1) * $end + $start;
	$req = "SELECT * FROM ".$_GET['idtab'].$tri." LIMIT ".$start2." , ".$end;
	$sql->query($req);
	$rows = $sql->num_rows();
	$array = array();
	while ($res = $sql->fetch_array())
		$array[] = $res;
?>	

